package cn.iocoder.yudao.module.bpm.dal.mysql.oa;

import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.BpmOaLeavePageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOaLeaveDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.ibatis.annotations.Mapper;

/**
 * 请假申请 Mapper
 *
 * @author jason
 * @author 芋道源码
 */
@Mapper
public interface BpmOaLeaveMapper extends BaseMapperX<BpmOaLeaveDO> {

    /**
     * 查询分页
     *
     * @param userId 用户id
     * @param reqVO  请求VO
     * @return {@code PageResult<BpmOaLeaveDO>}
     */
    default PageResult<BpmOaLeaveDO> selectPage(Long userId, BpmOaLeavePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BpmOaLeaveDO>()
                .eqIfPresent(BpmOaLeaveDO::getUserId, userId)
                .eqIfPresent(BpmOaLeaveDO::getResult, reqVO.getResult())
                .eqIfPresent(BpmOaLeaveDO::getType, reqVO.getType())
                .likeIfPresent(BpmOaLeaveDO::getReason, reqVO.getReason())
                .betweenIfPresent(BpmOaLeaveDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BpmOaLeaveDO::getId));
    }

}
